<template>
	<view class="">
		<customHead
			title="公告详情"
			isShowBackArrow
			:titlePaddingLeft="30"
			color="#000"
			:placeholder="true"
			navi_background="#fff"
		>
		</customHead>
		<view style="padding: 20rpx;">
			<view class="" style="font-size: 36rpx;font-weight: 700;">
				{{info.title}}
			</view>
			<view class="" style="font-size: 26rpx;color: #333;padding: 20rpx 0;">
				{{info.createTime}}
			</view>
			<view class="" >
				<image style="width: 100%;border-radius: 20rpx;" :src="info.activityImgUrl" mode="widthFix"></image>
			</view>
			<view class=""style="font-size: 26rpx;color: #333;margin-top: 20rpx;">
				<u-parse :content="info.content"></u-parse>
			</view>
			<view class="file_button">
				<button
					type="primary"
					style="width: 40vw;margin-top: 20rpx;" 
					size="mini" 
					@click="readFile()"
					v-if="info.detailsImgAndPageUrl"
				>
					<text>查看附件详情</text>
				</button>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		data() {
			return {
				info:{}
			}
		},
		onLoad(options) {
			console.log(options);
			this.info = JSON.parse(decodeURIComponent(options.info));
			console.log(this.info);
			uni.setNavigationBarTitle({
				title: this.info.title
			});
		},
		methods: {
			readFile () {
				let url = this.info.detailsImgAndPageUrl;
				uni.downloadFile({
				  url: url,
				  success: function (res) {
				    var filePath = res.tempFilePath;
				    uni.openDocument({
				      filePath: filePath,
				      showMenu: true,
				      success: function (res) {
				        console.log('打开文档成功');
				      }
				    });
				  }
				});
			},
		}
	}
</script>

<style>
	.file_button{
		width: 100%;
		display: flex;
		justify-content: center;
		margin-bottom: 30rpx;
	}
</style>
